new Vue({
    el: '#app',
    data: {
        total: 0,
        pageIndex: 1,
        pageSize: 10,
        pageCon: 1,
        msg: '',
        member: {},
        infoList: [],
        SERVER_HOST: SERVER_HOST,
        id: ''
    },
    mounted () {
        var member = Cookies.get('member');
        if (!member || member == null || member == '') {
            window.location.href = 'dl.html';
        } else {
            this.member = JSON.parse(member);
            this.load();
        }
    },
    methods: {
        exit () {
            Cookies.remove('member');
            window.location.href = 'dl.html';
        },
        load () {
            let formData = {};
            formData['page'] = this.pageIndex;
            formData['size'] = this.pageSize;
            formData['memberId'] = this.member['id'];
            getAjax().post('/web/infoList', toFormData(formData)).then(res => {
                if (res.data.data) {
                    this.infoList = res.data.data.list;
                    this.total = res.data.data.total;
                    this.pageCon = Math.ceil(this.total / this.pageSize);
                    this.infoList.forEach(item => {
                        item.pushTime = getDate(item.pushTime);
                        if (item.status == 1) {
                            item.status = '已读';
                        } else {
                            item.status = '未读';
                        }
                    });
                }
            });
        },
        pageSelect (pageIndex) {
            if (pageIndex < 1 || pageIndex > this.pageCon) return;
            this.pageIndex = pageIndex;
            this.load();
        }
    }
});
